package com.sun.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sun.common.MsResult;
import com.sun.pojo.PmsProductAttribute;
import com.sun.service.IPmsProductAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 产品属性分类表 前端控制器
 * </p>
 *
 * @author 妙妙屋
 * @since 2021-12-27
 */
@RestController
@RequestMapping("/productAttribute")
public class PmsProductAttributeController {

    @Autowired
    private IPmsProductAttributeService pmsProductAttributeService;

    @GetMapping("/list/{id}")
    public MsResult list(@PathVariable Long id, Long pageNum, Long pageSize, Long type){
        //type 1表示属性列表，  0表示参数列表
        Page<PmsProductAttribute> p = new Page<>(pageNum, pageSize);
        QueryWrapper<PmsProductAttribute> qr = new QueryWrapper<>();
        qr.eq("type",type);
        qr.eq("product_attribute_category_id",id);
        Page page = pmsProductAttributeService.page(p, qr);
        return MsResult.isOkDataPage(page);
    }
}

